<?php
@session_start ();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="../u_css/goods_detail.css" rel="stylesheet" type="text/css" />
<title>商品详细信息</title>
</head>
<body>
<?php
include '../include_htmls/header.php';
require '../mysql_connection/for_u_lijinsheng.php';
$id = $_GET ["id"];
$good = get_Good ( $id );

if (isset ( $_GET ['buy'] )) {
	if (isset ( $_SESSION ['goods'] )) {
		$_SESSION ['goods'] [count ( $_SESSION ['goods'] )] = $_GET ['id'];
	} else {
		$_SESSION ['good'] = array ($_GET ['id'] );
	}
	unset ( $_GET ['buy'] );
	unset ( $_GET ['id'] );
}

if (isset ( $_POST ['username'] )) {
	add_comment ( $_POST ['username'], $_POST ['goods_id'], $_POST ['comment'], $_POST ['grade'] );
	$good = get_Good ( $_POST ['goods_id'] );
	unset ( $_POST ['username'] );
	unset ( $_POST ['goods_id'] );
	unset ( $_POST ['grade'] );
	unset ( $_POST ['comment'] );
}
?>
<div id="body"><a
	href="http://localhost/e-commerce/user_php/big_picture.php?id=<?=$good [0]?>"><img
	src="<?=$good [3]?>"></img> </a>
<p>产品名称：<?=$good [1]?></p>
<p>产品价格：$<?=$good [2]?></p>
<form action="goods_detail.php" method="get">
<div><input type="hidden" name="id" value=<?=$id?> /> <input
	type="hidden" name="buy" value="true" /> <input type="submit"
	value="添加到购物车" /></div>
</form>
<div id="comment">
<?php
$comments = get_comments ( $good [0] );
foreach ( $comments as $comment ) {
	?>
	<hr />
<p><?=$comment?></p>
<hr />
	<?php
}
if (isset ( $_SESSION ['username'] )) {
	?>
	<form action="goods_detail.php" method="post">
<div><input type="hidden" name="username"
	value="<?=$_SESSION ['username']?>" /> <input type="hidden"
	name="goods_id" value="<?=$good [0]?>" /> <label>给商品评分:<select
	name="grade">
	<option>1</option>
	<option>2</option>
	<option>3</option>
	<option>4</option>
	<option>5</option>
</select></label> <textarea name="comment" rows="3" cols="40">
添加评论
</textarea> <input type="submit" value="评论" /></div>
</form>
<?php
}
?>
</div>
</div>
<?php
include '../include_htmls/footer.html';
?>
</body>
</html>